package com.xxg.renrenproduct.dao;

import com.xxg.renrencommon.domain.dao.BaseMapper;
import com.xxg.renrencommon.domain.dao.RenrenShopGoodsOption;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * RenrenShopGoodsOptionDao继承基类
 */
@Mapper
@Repository
public interface RenrenShopGoodsOptionDao extends BaseMapper<RenrenShopGoodsOption, Integer> {
    @Select("SELECT count(*) FROM renren_shop_goods_option WHERE id = #{id,jdbcType=INTEGER}")
    long countById(Integer id);

    @Select("SELECT id, shop_id as shopId, sub_shop_id as subShopId, goods_id as goodsId, title, thumb, price, cost_price as costPrice, original_price as originalPrice, \n" +
            "    stock, stock_warning as stockWarning, sales, weight, goods_code as goodsCode, bar_code as barCode, specs, display_order as displayOrder, \n" +
            "    virtual_account_id as virtualAccountId FROM renren_shop_goods_option WHERE goods_id = #{goodsId,jdbcType=INTEGER}")
    List<RenrenShopGoodsOption> selectByGoodsId(Integer goodsId);

    int insertBatch(@Param("items") List<RenrenShopGoodsOption> newRenrenShopGoodsOptions);

    @Delete("DELETE FROM renren_shop_goods_option WHERE goods_id = #{goodsId,jdbcType=INTEGER}")
    void deleteByGoodsId(Integer goodsId);

}